import 'package:flutter/material.dart';
import 'package:flutter_levin/config/router_manager.dart';
import 'package:flutter_levin/config/storage_manager.dart';
import 'package:flutter_levin/config/ui_adapter_config.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:pull_to_refresh_flutter3/pull_to_refresh_flutter3.dart';

// ignore: library_prefixes
import 'config/router_manager.dart' as RouterManager;

void main() async {
  var widgetsBinding = InnerWidgetsFlutterBinding.ensureInitialized();

  await StorageManager.init();
  widgetsBinding
    ..attachRootWidget(const MyApp())
    ..scheduleForcedFrame();
  // ToolbarUtils.setBarStatus(true);
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return RefreshConfiguration(
      hideFooterWhenNotFull: true,
      headerBuilder: () => const ClassicHeader(
        releaseText: '松开刷新',
        refreshingText: '正在加载...',
        failedText: '加载失败!!!',
        completeText: '加载完成',
        idleText: '下拉刷新',
      ),
      footerBuilder: () => const ClassicFooter(
        noDataText: '我是有底线的~',
        loadingText: '正在加载',
        failedText: '加载失败!!!',
        idleText: '上拉加载更多',
        canLoadingText: '松开开始加载',
      ),
      child: MaterialApp(
        title: 'flutter levin',
        debugShowCheckedModeBanner: false,
        darkTheme: ThemeData(
            colorScheme: const ColorScheme.dark(brightness: Brightness.dark),
            // brightness: Brightness.light,
            primaryColor: Colors.black,
            primaryColorDark: Colors.black,
            splashColor: Colors.white38,
            focusColor: Colors.white54,
            scaffoldBackgroundColor: Colors.black26,
            backgroundColor: Colors.black26,
            textTheme:
                const TextTheme(subtitle1: TextStyle(color: Colors.black))),
        theme: ThemeData(
            colorScheme: const ColorScheme.light(brightness: Brightness.light),
            // brightness: Brightness.dark,
            primaryColor: Colors.white,
            primaryColorDark: Colors.white,
            splashColor: Colors.black54,
            focusColor: Colors.black87,
            scaffoldBackgroundColor: const Color(0xFFF2F2F2),
            backgroundColor: Colors.white,
            toggleableActiveColor: Colors.blueAccent),
        themeMode: ThemeMode.system,
        onGenerateRoute: RouterManager.Router.generateRouter,
        initialRoute: RouteName.splash,
        builder: EasyLoading.init(),
      ),
    );
  }
}
